package com.citywithincity.db.data2db;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.citywithincity.api.ApiBuildConfig;
import com.citywithincity.db.interfaces.IPsSetter;

/**
 * 日期转为字符串
 * 
 * @author randy
 *
 */
class Date2String implements IPsSetter {

	@Override
	public void setValue(PreparedStatement ps, int index, Object value) throws SQLException {
		if (value == null) {
			ps.setObject(index, null);
		} else {
			ps.setString(index, new SimpleDateFormat(ApiBuildConfig.DATE_TIME_FORMAT).format((Date) value));
		}
	}

}
